//
//  ViewController.m
//  scrollview代理
//
//  Created by song on 15/1/9.
//  Copyright (c) 2015年 song. All rights reserved.
//

#import "ViewController.h"

@interface ViewController () <UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@property (weak, nonatomic) IBOutlet UIImageView *miniView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.scrollView.contentSize = self.miniView.frame.size;
    self.scrollView.showsHorizontalScrollIndicator =NO;
    self.scrollView.showsVerticalScrollIndicator =NO;
    self.scrollView.delegate= self;
    //设置最大 最小的缩放比例
    self.scrollView.minimumZoomScale =0.2;
    self.scrollView.maximumZoomScale = 2.0;
    
    
}
// 用户开始拖拽的时候调用
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    NSLog(@" 开始拖拽");
}

// 滚动的某个位置时候调用
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@" ----滚动到某个位置 -- %@", NSStringFromCGPoint(self.scrollView.contentOffset));
    

}

// 用户结束拖拽的时候调用
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    NSLog(@" 结束拖动 ");
}

// 用户使用捏合手势的时候调用
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    NSLog(@"--------开始缩放 ");
    return self.miniView;
}

-(void)scrollViewDidZoom:(UIScrollView *)scrollView
{
    NSLog(@"--- 正在缩放 ");
}

// 当用户开始拖拽 scrollview 时候回调用这个方法
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    // Dispose of any resources that can be recreated.
}

@end
